package com.example.controller;

import com.example.feign.MyFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 本类用来演示:  隔离性,拿不到其他组的实例的,只能拿到一个组里面的实例,
 *
 * @Author 胡英俊
 * @Date 2022/7/24 23:13
 */
@RestController
public class discoveryNacos {
    @Autowired
    private DiscoveryClient discoveryClient;
    @Autowired
    private MyFeign feign;
    @GetMapping("getTest")
    public String getServiceInstance(){
        List<ServiceInstance> instances = discoveryClient.getInstances("user-service");
        System.out.println(instances);
        String info = feign.getInfo();
        return info;
    }
}
